Search for: ^\s+|\s+$
Replace with: empty
Options/Current selection only: ON
Options/Regular expressions: ON

Click Replace All